<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try {
				ace.settings.check('breadcrumbs', 'fixed')
			} catch (e) {}
		</script>

		<!-- .breadcrumb -->
	</div>
	<!-- Main content -->
	<div class="page-content">
		<div class="row">
			<div class="page-header">
				<h1>电商管家子商户</h1>
			</div>
			<div class="col-md-12 col-sm-12 col-xs-12 form">
				<a class="btn btn-info btn-sm" href="<?php echo base_url() . "admin/systems/add_citic_merchant/" ?>"><i class="icon-copy"></i>新增</a>
				<div style="float: right;"><b>总误差:<span style="color: <?php if ($error_total >= 0) {
																			echo 'green';
																		} else {
																			echo 'red';
																		} ?>"><?php echo $error_total ?></span></b></div>
			</div>
			<div class="col-md-12 col-sm-12 col-xs-12">
				<h3 style="margin-bottom: 10px;">总览</h3>
				<style type="text/css">
					.sum{border: 0;}
					.sum th{border: 0 !important;}
					.sum td{border: 0 !important;border-bottom-width:0;border-top:0;}
				</style>
				<table class="table table-striped table-bordered table-hover sum">
					<thead>
						<tr>
							<th>订单金额</th>
							<th>入账金额</th>
							<th>总渠道费</th>
							<th>结算金额</th>
							<th>钉铛分成</th>
							<th>订单总数</th>
							<th>新增用户</th>
							<th>订单均价</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td><span style="color: red;"><?php echo $summary['order_price']?></span></td>
							<td><span style="color: red;"><?php echo $summary['remain_price']?></span></td>
							<td><span style="color: red;"><?php echo $summary['channel_fee']?></span></td>
							<td><span style="color: red;"><?php echo $summary['merch_price']?></span></td>
							<td><span style="color: red;"><?php echo $summary['commission']?></span></td>
							<td><span style="color: red;"><?php echo $order_total?></span></td>
							<td><span style="color: red;"><?php echo $new_user?></span></td>
							<td><span style="color: red;"><?php echo $average?></span></td>
						</tr>
					</tbody>
				</table>
			</div>
			<div class="col-xs-12 margin_t margin_b">
				<div class="table-responsive  tab">
					<h3 style="margin-bottom: 10px;">误差订单</h3>
					<table id="sample-table-1" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th style="width: 12%">油站名称</th>
								<th style="width: 10%">应付金额</th>
								<th style="width: 10%">实付金额</th>
								<th style="width: 12%">误差</th>
								<th style="width: 12%">结算日期</th>
								<th style="width: 8%">操作</th>
							</tr>
						</thead>
						<tbody>
							<?php if (isset($result) && count($result) > 0) {
								foreach ($result as $rs) {
									?>
									<tr>
										<td>
											<p><?php echo $rs['gasstation_name']; ?></p>
										</td>
										<td>
											<p><?php echo $rs['should_pay']; ?></p>
										</td>
										<td>
											<p><?php echo $rs['error_price']; ?></p>
										</td>
										<td>
											<p style="color: <?php if ($rs['error_price'] - $rs['should_pay'] > 0) {
																			echo 'green';
																		} else {
																			echo 'red';
																		} ?>"><?php echo round($rs['error_price'] - $rs['should_pay'], 2); ?></p>
										</td>
										<td>
											<p><?php echo $rs['date']; ?></p>
										</td>
										<td>
											<a target="_blank" href="<?php echo base_url() . 'admin/order/query?order_no=' . $rs['order_no'] ?>" class="btn btn-warning btn-sm"><i class="icon-edit"></i>详细订单</a>
											<a target="_blank" href="<?php echo base_url().'admin/systems/edit_citic/'.$rs['order_no']?>" class="btn btn-info btn-sm"><i class="icon-edit"></i>编辑订单</a>
										</td>
									</tr>
								<?php }
								} else { ?>
								<tr>
									<td colspan="14">无数据</td>
								</tr>
							<?php } ?>
						</tbody>
					</table>
					<button class="btn btn-info btn-sm pass">审核通过</button>
					<button class="btn btn-danger btn-sm remake">重新生成文件</button>
				</div><!-- /.table-responsive -->
				<script type="text/javascript">
					var code = 1;
					var date = '<?php echo $date ?>';
					$('.pass').click(function() {
						$.post('<?php echo base_url() ?>/admin/citicBat/uploadOrderFile', {
							code: code,
							date: date
						}, function(res) {
							rel = JSON.parse(res);
							for (var i = rel.length - 1; i >= 0; i--) {
								if(rel[i]['RSP_CODE'] != '00000'){
									alert(rel[i]['RSP_MSG']);
									return;
								}else{
									if(i == 0){
										alert('上传成功!');
									}
								}
							}
							console.log(rel);
						})
					})
					$('.remake').click(function() {
						var date = '<?php echo $date ?>';
						$.post('<?php echo base_url() ?>/admin/citicBat/remake', {
							date: date
						}, function(res) {
							res = JSON.parse(res);
							alert(res.msg);
						})
					})
				</script>
			</div>

		</div><!-- /.row -->
	</div><!-- /.page-content -->
</div><!-- /.main-content -->